<?php
	require_once('./headers/data.php');

    class participant {
    	private $dni;
		private $nom;
		private $tlf;
		private $correu;
		private $sexe;
		private $nivell;
		private $restriccions;
		
		public function setDadesBasic($dni, $nom, $sexe, $niv, $n_dies){
			$this->dni = $dni;
			$this->nom = $nom;
			$this->sexe = $sexe;
			$this->nivell = $niv;
			$this->restriccions = array();
			for ($i=0; $i < $n_dies; $i++) { 
				$this->restriccions[$i] = array();
				for ($j=0; $j < 3; $j++) { 
					$this->restriccions[$i][$j] = FALSE;
				}
			}
		}
		
		public function getDni(){
			return $this->dni;
		}
		
		public function getNom(){
			return $this->nom;
		}
		
		public function getRes(){
			return $this->restriccions;
		}
		
		public function setRestriccions($dia, $mati, $migdia, $tarda){

			if($mati){
				$this->restriccions[$dia][0] = TRUE;	// 0=9-13
			}
			if($migdia){
				$this->restriccions[$dia][1] = TRUE;	// 1=13-17
			}
			if($tarda){
				$this->restriccions[$dia][2] = TRUE;	// 2=17/22
			}
			
		}
		
		public function potJugar($data){
			$in = $data->getHoraIni();
			if($in < 13)		$h = 0;
			else if($in < 17)	$h = 1;
			else 				$h = 2;
			
			return !$this->restriccions[$data->getDia()][$h];
		}
    }
?>